{include file="public/head"}
<div class="main">
    {include file="public/left"}
    <div class="middle">
    {include file="public/header"}
    <ul class="release_tab">
        <dl>
            <span>{:__('发布任务只需')}</span>
            <span class="num">3</span>
            <span>{:__('步')}</span>
        </dl>
        <dl>{:__('选择任务模式')}<span class="num2">1</span></dl>
        <dt>{:__('描述任务需求')}<span class="num1">2</span></dt>
        <dl>{:__('任务订单确认')}<span class="num2">3</span></dl>
    </ul>
    <ul class="task_sub">
        <h3>{:__('悬赏任务>>描述需求')}</h3>
        <h6 style="width: 98%;padding:1%;background-color: rgb(255,230,181);"><i style="color: #ff0b0b;font-size: 16px;margin-right: 3px;" class="fa fa-exclamation-circle"  aria-hidden="true"></i>{:__('当前交易皆为金币交易')}</h6>
        <dt>
            <p><span class="task_choose">{:__('基本需求')}</span><span>{:__('赏金分配')}</span><span>{:__('高级需求')}</span><span>{:__('发布规则与协议')}</span></p>
            <dl>
                <h2 class="task_title">{:__('基本需求')}</h2>
                <div>
                    <h5>{:__('任务分类')}</h5>
                    <p class="task_class">
                        <select  class="layui-input" id="cat_id_1">
                            <option value="0">{:__('请选择分类')}</option>
                        </select>
                        <i class="layui-icon">&#xe61a;</i>
                        <select class="layui-input" id="cat_id">
                            <option value="0">{:__('请选择子行业')}</option>
                        </select>
                        <i class="layui-icon">&#xe61a;</i>
                        <span class="class_tip">{:__('(你的任务需要哪一类人才来完成呢)')}</span>
                    </p>
                </div>
                <div>
                    <h5>{:__('任务标题')}</h5><span>{:__('你想悬赏什么')}？</span>
                    <p class="title_p"><input id="title" type="text" class="layui-input task_title_input"/><span class='title_tip'>({:__('你想做什么')}？)</span></p>
                </div>
                <div>
                    <h5>{:__('任务描述')}</h5><span>{:__('尽量把问题说清楚，以便准确分析')}</span>
                    {include file="public/editor"}
                </div>
                <div>
                    <h5>{:__('附件')}</h5><span>{:__('任务要求太多，我写在附件里了')}</span>
                    <p class="enclosure"><a class='click_enclosure' id="click_enclosure">{:__('点击添加附件')}</a>
                         <span class='enclosure_rule'>({:__('允许上传附件格式')}:.xls,.xlsx,.doc,.docx,.zip,.rar,.jpg,.png,.gif .{:__('上限')}10M)</span></p>
                    <p class="attach_p">
                        <input style="display: none;" id="attach" class="attach layui-btn layui-btn-primary" type="file"/>
                        <button id="attach_copy" class="layui-btn layui-btn-primary">{:__('选择文件')}</button><span id="file_name">{:__("请选择上传的文件")}</span>
                        <button style="display: none;" id="attach_sub" class="attach_sub layui-btn layui-btn-primary">{:__('上传')}</button><a style="margin-left: 5px;" id="cancle_attach">{:__('取消')}</a>
                    </p>
                </div>
            </dl>
            <p><span>{:__('基本需求')}</span><span class="task_choose">{:__('赏金分配')}</span><span>{:__('高级需求')}</span><span>{:__('发布规则与协议')}</span></p>
            <dl>
                <h2 class="task_title">{:__('赏金分配')}</h2>
                <div>
                    <h5>{:__('任务金额')}</h5><span>{:__('我希望发布的任务金额为')}({:__('最多金额为')}9999)</span>
                    <p class="money_p">
                        <input id="money" type="text" class="layui-input"/><span class="money_tip">$</span>
                        <i class="fa fa-exclamation-triangle warn" aria-hidden="true"></i>
                        <a>{:__('赏金必须为数字')}</a>
                        <select class="layui-input" id="slt_bid_mode">
                            <option value="1">{:__('只选择一人中标')}</option>
                            <option value="2">{:__('选择多人中标')}</option>
                            <option value="3">{:__('计件中标,合格一个算一个')}</option>
                        </select>
                        <i class="layui-icon">&#xe61a;</i>
                    </p>
                    <p class="money_way">
                        <span>{:__('赏金总额$,您希望怎么分配奖金')}?</span>
                    </p>
                    <p class="money_setting">
                        <span>{:__('你的赏金怎样进行分配,也影响到稿件质量')}</span><a id="add_setting">{:__('增加奖项')}</a><a id="del_setting">{:__('取消奖项')}</a><span>({:__('最多只能设定三个奖项')})</span>
                    </p>
                    <p class="money_setting">
                        <span>1&nbsp;{:__('等奖')}</span><input type="text" id="people_1" class="layui-input"/><span>{:__('人,平分奖金的')}</span><input id="money_1" type="text" class="layui-input"/><span>$({:__('单价')})</span>
                    </p>
                    <p class="money_piece">
                        <span>{:__('计件任务单价不能低于')}1$</span>
                    </p>
                    <p class="piece_input">
                        <input id="gj_num" type="text" class="layui-input"/><span>{:__('个稿件')} ，{:__('每个')}</span><input id="gj_money" type="text" class="layui-input"/><span>$</span>
                    </p>
                </div>
            </dl>
            <p><span>{:__('基本需求')}</span><span>{:__('赏金分配')}</span><span class="task_choose">{:__('高级需求')}</span><span>{:__('发布规则与协议')}</span></p>
            <dl>
                <h2 class="task_title">{:__('高级需求')}</h2>
                <div>
                    <h5>{:__('任务时间周期')}</h5><span>{:__('你希望能按多长时间完成任务')}({:__('最多')}99)</span>
                    <p class='expire_p'><input id="days_expire" type="text" class="layui-input expire_input"/><span class="expire_tip">{:__('天')}</span></p>
                </div>
                <div>
                    <h5>{:__('报名人数限制')}({:__('最多')}999)</h5>
                    <p class='sign_p'><input id="sign_limit" type="text" class="layui-input sign_input" value='50'/><span class="sign_tip">{:__('人')}</span></p>
                </div>
                <div>
                    <h5>{:__('联系方式')}</h5><span>{:__('数据来源于')}<a style="color: red !important;text-decoration: underline;" id="changprofile">{:__('基本资料')}</a></span>
                    <p class='connect_p'><input disabled id="connect" style="border: white;" type="text" class="layui-input connect_input"/></p>
                </div>
            </dl>

            <p><span>{:__('基本需求')}</span><span>{:__('赏金分配')}</span><span>{:__('高级需求')}</span><span class="task_choose">{:__('发布规则与协议')}</span></p>
            <dl>
                <h2 class="task_title">{:__('发布规则与协议')}</h2>
                <p class="rule_input"><input id="read_rule" type="checkbox"/><a id="task_rule" class="task_rule">{:__('我已阅读并接受《赏金写手网雇主规则》')}</a></p>
                <p class='rule_detail'>
                    {:__('本着公开、公平、公正、诚实、守信的原则，致力于打造中国最具诚信的创意服务电子商务交易平台。请在您发布任务前仔细阅读任务发布规则')}：<br/>
                    {:__('1、任务发布者自由定价，自由确定悬赏时间，自由发布任务要求，自主确定中标会员和中标方案')}。<br/>
                    {:__('2、任务发布者100%预付任务赏金，让竞标者坚信您的诚意和诚信')}。<br/>
                    {:__('3、悬赏任务赏金分配原则：任务一经发布，网站收取一定发布费')}。<br/>
                    {:__('4、招标任务赏金分配原则：任务一经发布，网站不收取发布费，中标会员获得赏金的100%')}。<br/>
                    {:__('5、任务发布者若未征集到满意作品，可以加价延期征集，也可让会员修改')}。<br/>
                    {:__('6、任务发布者自己所在组织的任何人均不能以任何形式参加自己所发布的任务，一经发现则视为任务发布者委托网站管理员按照网站规则选稿')}。<br/>
                    {:__('7、延期任务有次数限制，并且每次必须增加一定比例的佣金')}。<br/>
                    {:__('8、保证审稿的公平性，请雇主及时审核贴子是否合格。如雇主没及时审核贴子，系统默认雇主同意支付')}。<br/>
                    {:__('9、任务选稿后，网站将公示一段时间，以便查看该任务是否有抄袭作弊的情况。公示期结束，同时发布者和中标者完成源文件的交接事宜后，由发布者确认源文件无误，网站将任务赏金支付给中标者，但发布者如出现恶意拖款的情况，一旦查证属实，将视为全权委托网站工作人员处理')}。<br/>
                    {:__('10、发布者与投标会员，应严格按照每个任务的“任务要求”所描述的内容执行。如果发布者提出超出“任务要求”范围的要求，会员有权拒绝，发布者也不得以此为理由拒绝选出中标方案或退款')}。<br/>
                    {:__('11、会员在中标后被举报涉嫌抄袭的作品，经过调查核实，本站取消中标资格')}。<br/>
                    {:__('12、发布任务即视为同意本协议')}。
                </p>
            </dl>
            <p class="links"><a href="/index/Index/release">{:__('返回上一步')}</a><a class="layui-btn layui-btn-primary next">{:__('下一步')}</a></p>
        </dt>
    </ul>
    {include file="public/foot"}
    </div>
    {include file="public/right"}
</div>
{include file="public/footer"}
<script>
    noLog();
    $(".rule_detail").css('display','none');
    $(document).queue('user',function(){
        var userData = getLocalStorage('userData');
        var userdata = JSON.parse(userData);
        if(userdata['phone'] != '' && userdata['phone'] != null && userdata['phone'] != undefined){
            $("#connect").val(userdata['phone']);
        } else {
            $("#connect").val(userdata['email']);
        }
    });

    $(".money_way,.money_setting").css("display","none");
    $(".money_piece,.piece_input").css("display","none");

    $("#reward_task").on("mouseover",function(){
        var title = $(this).attr("data-title");
        layer.tips(title,      
        this, 
        {tips:[3, '#ffffff'], time:3000});
    });
    $("#task_rule").click(function(){
        if($(".rule_detail").css('display') == 'flex'){
            $(".rule_detail").css('display','none');
        } else {
            $(".rule_detail").css('display','flex');
        }
    });
    $("#click_enclosure").click(function(){
        if($(".attach_p").css("display") == 'none'){
            $(".attach_p").css("display",'flex');
        } else {
            $(".attach_p").css("display",'none');
        }
    });
    $(document).on('click',"#cancle_attach",function(){
        var index = layer.confirm("{:__('是否确定取消上传?')}",{icon: 3, title:'{:__("提示")}',btn:['{:__("确定")}','{:__("取消")}']},function(){
            $("#attach").removeAttr("src");
            $("#file_name").html('{:__("请选择上传的文件")}');
            $(".attach_p").css("display",'none');
            layer.close(index);
        });
    });
    var mission_category = getLocalStorage('mission_category');
    function get_mission_category()
    {
        htl = "";
        mission_category = getLocalStorage('mission_category');
        mission_categoryObj = JSON.parse(mission_category);
        for(i in mission_categoryObj){
            htl += '<option value="'+mission_categoryObj[i]['id']+'">'+mission_categoryObj[i]['name']+'</option>';
        }
        $("#cat_id_1").append(htl);
        $(document).dequeue('task_class');
    }
    // 获取分类及获取编辑
    $(document).queue('task_class',function(){
        if(mission_category != null && mission_category != '' && mission_category != undefined){
            get_mission_category();
        }  else {
            objs = {
                'mission_category':1
            };
            CacheLoad(objs);
            $(document).queue("mission_category,",function(){
                get_mission_category();
            });
        }
    });
    $("#cat_id_1").click(function(){
        var _this = $(this);
        var htl = '<option value="0">{:__("请选择子行业")}</option>';
        var mission = getLocalStorage("mission_category");
        var mission_category = JSON.parse(mission);
        var cat_id_1 = _this.val();
        if(cat_id_1 == 0){
            $("#cat_id").html(htl);
            return false;
        }
        cat_id_1 = parseInt(cat_id_1);
        var _child = mission_category[cat_id_1]['_child'];
        for(i in _child){
            htl += "<option value='"+_child[i]['id']+"'>"+_child[i]['name']+"</option>";
        }
        $("#cat_id").html(htl);
    });
    $("#slt_bid_mode").click(function(){
        var _this = $(this);
        if(_this.val() == 1){
            $(".money_way,.money_setting").css("display","none");
            $(".money_piece,.piece_input").css("display","none");
        } else if(_this.val() == 2){
            $(".money_way,.money_setting").css("display","flex");
            $(".money_piece,.piece_input").css("display","none");
        } else if(_this.val() == 3){
            $(".money_way,.money_setting").css("display","none");
            $(".money_piece,.piece_input").css("display","flex");
        }
    });
    $("#add_setting").click(function(){
        var len = $(".money_setting").length;
        if(len > 3){
            layer.msg("{:__('最多只能设置三个奖项')}",{icon:3});
            return false;
        }
        var htl = '<p class="money_setting"><span>'+len+'&nbsp;{:__("等奖")}</span><input id="people_'+len+'" type="text" class="layui-input"/><span>{:__("人,平分奖金的")}</span><input id="money_'+len+'" type="text" class="layui-input"/><span>$({:__("单价")})</span></p>';
        $(".money_piece").before(htl);
    });
    $("#del_setting").click(function(){
        var len = $(".money_setting").length;
        len = parseInt(len)-1;
        if(len <2){
            layer.msg("{:__('一等奖不能取消')}",{icon:3});
            return false;
        }
        $(".money_setting").eq(len).remove();
    });
    $(document).queue('task_class',function(){
        res = localStorage.getItem("taskinfo");
        ret = JSON.parse(res);
        if(ret != '' && ret != null && ret != undefined){
            if(ret['cat_id_1'] != '' && ret['cat_id_1'] != null  && ret['cat_id_1'] != undefined){
                $("#cat_id_1").val(ret['cat_id_1']);
                $("#cat_id_1").trigger("click");
            }
            if(ret['cat_id'] != '' && ret['cat_id'] != null  && ret['cat_id'] != undefined){
                $("#cat_id").val(ret['cat_id']);
            }
            if(ret['title'] != '' && ret['title'] != null  && ret['title'] != undefined){
                $("#title").val(ret['title']);
            }
            if(ret['content'] != '' && ret['content'] != null  && ret['content'] != undefined){
                editor.txt.html(ret['content']);
            }
            if(ret['attach'] != '' && ret['attach'] != null  && ret['attach'] != undefined){
                $("#attach").attr('src',ret['attach']);
            }
            if(ret['money_cfg']['slt_bid_mode'] != '' && ret['money_cfg']['slt_bid_mode'] != null  && ret['money_cfg']['slt_bid_mode'] != undefined){
                $("#slt_bid_mode").val(ret['money_cfg']['slt_bid_mode']);
                $("#slt_bid_mode").trigger("click");
                if(ret['money_cfg']['slt_bid_mode'] == 2){
                    var nowlen = $(".money_setting").length;
                    var willlen = ret['money_setting'];
                    var len = willlen-nowlen;
                    for(var j=0;j<len;j++){
                        $("#add_setting").trigger("click");
                    }
                    nowlen = $(".money_setting").length;
                    for(i=1;i<nowlen;i++){
                        $("#people_"+i).val(ret['money_cfg']['txt_pople_'+i]);
                        $("#money_"+i).val(ret['money_cfg']['txt_avg_money_'+i]);
                    }
                } else if(ret['money_cfg']['slt_bid_mode'] == 3){
                    $("#gj_num").val(ret['money_cfg']['gj_num']);
                    $("#gj_money").val(ret['money_cfg']['gj_money']);
                }
            }
            if(ret['money'] != '' && ret['money'] != null  && ret['money'] != undefined){
                $("#money").val(ret['money']);
            }
            if(ret['days_expire'] != '' && ret['days_expire'] != null  && ret['days_expire'] != undefined){
                $("#days_expire").val(ret['days_expire']);
            }
            if(ret['sign_limit'] != '' && ret['sign_limit'] != null  && ret['sign_limit'] != undefined){
                $("#sign_limit").val(ret['sign_limit']);
            }
             
        }
    });
    // 获取分类及获取编辑
    $(document).dequeue('task_class');

    
    $("#attach_sub").click(function(){
        var formdata = new FormData();
        var files = $("#attach")[0].files[0];
        $("#cancle_attach").html("");
        if(files == '' || files == null || files == undefined ){
            layer.msg("{:__('请选择文件')}",{icon:2});
            $("#cancle_attach").html("{:__('取消')}");
            return false;
        }
        formdata.append("file",files);
        formdata.append("token",token);
        if(files['type'].indexOf('image')!=-1){
            formdata.append("file_type",'image');
        } else {
            formdata.append("file_type",'file');
        }
        $.ajax({
            url:'/api/common/upload',
            type:'post',
            data:formdata,
            processData:false,
            contentType:false,
            success:function(ret){
                if(ret.code != 401 && ret.code != 1){
                    layer.msg(ret.msg,{icon:2},function(){
                        $("#cancle_attach").html("{:__('取消')}");
                    });
                } else if(ret.code ==1){
                    layer.msg(ret.msg,{icon:1},function(){
                        if(ret['data']['file'] != '' && ret['data']['file'] != null && ret['data']['file'] != undefined){
                            $("#attach").attr("src",ret['data']['file']['attach_id']);
                            $("#cancle_attach").html("{:__('取消')}");
                        }
                    });
                } else {
                    $("#cancle_attach").html("{:__('取消')}");
                }
                
            },error:function(){
                $("#cancle_attach").html("{:__('取消')}");
            }
        });
    });
    $(document).on('keydown',"#sign_limit,#gj_num,#people_1,#people_2,#people_3",function(e){
        var _this = $(this);
        var flag = keyLimit(e,0,_this);
        if(flag == false){
            return false;
        }
    });
    $(document).on('keydown',"#gj_money,#money_1,#money_2,#money_3,#money",function(e){
        var _this = $(this);
        var flag = keyLimit(e,4,_this);
        if(flag == false){
            return false;
        }
    });
    $(document).on('keydown',"#days_expire",function(e){
        var _this = $(this);
        var flag = keyLimit(e,2,_this);
        if(flag == false){
            return false;
        }
    });
    $(document).on('keydown',"#sign_limit",function(e){
        var _this = $(this);
        var flag = keyLimit(e,3,_this);
        if(flag == false){
            return false;
        }
    });
    
    $(".next").click(function(){
        var cat_id_1 = $("#cat_id_1").val();
        cat_id_1 = parseInt(cat_id_1);
        if(cat_id_1 <= 0){
            layer.msg("{:__('任务分类不能为空')}",{icon:3});
            return false;
        }
        var cat_id = $("#cat_id").val();
        cat_id = parseInt(cat_id);
        if(cat_id <= 0){
            layer.msg("{:__('任务分类子行业不能为空')}",{icon:3});
            return false;
        }
        var title = $("#title").val();
        if(title == '' || title == null || title == undefined){
            layer.msg("{:__('任务标题不能为空')}",{icon:3});
            return false;
        }
        titletmp = title.replace(/ /g,'').replace(/&nbsp;/g,'');
        if(titletmp.length>50){
            layer.msg("{:__('任务标题不能大于50个字符')}",{icon:3});
            return false;
        }
        var content = editor.txt.html();
        if(content == '' || content == null || content == undefined){
            layer.msg("{:__('任务描述不能为空')}",{icon:3});
            return false;
        }
        contenttmp = editor.txt.text().replace(/ /g,'').replace(/&nbsp;/g,'');
        if(contenttmp.length<10){
            layer.msg("{:__('任务描述不能小于10个字符')}",{icon:3});
            return false;
        }
        var attach = $("#attach").attr("src");
        if(attach == '' || attach == null || attach == undefined){
            attach = '';
        }
        var  money = $("#money").val();
        moneycopy = parseInt(money);
        if(money == '' || money == null || money == undefined || money == 0){
            layer.msg("{:__('任务金额不能为空或0')}",{icon:3});
            return false;
        }
        if(money != moneycopy){
            layer.msg("{:__('任务金额只能为整数')}",{icon:3});
            return false;
        }
        var slt_bid_mode = $("#slt_bid_mode").val();
        slt_bid_mode = parseInt(slt_bid_mode);
        if(slt_bid_mode == 2){
            var money_flag = 0;
            var people_flag = 0;
            var len = $(".money_setting").length;
            var allmoney = 0;
            for(i=1;i<len;i++){
                // 平分奖金校验
                var txt_avg_money = $("#money_"+i).val();
                var txt_avg_moneyint = parseInt(txt_avg_money);
                if(txt_avg_money == '' || txt_avg_money == null || txt_avg_money == undefined || txt_avg_money == 0){
                    money_flag = 1;
                }
                if(txt_avg_money != txt_avg_moneyint){
                    money_flag = 1;
                }
                // 人数校验
                var txt_pople = $("#people_"+i).val();
                var txt_popleint = parseInt(txt_pople);
                if(txt_pople == '' || txt_pople == null || txt_pople == undefined || txt_pople == 0){
                    people_flag = 1;
                }
                if(txt_pople != txt_popleint){
                    people_flag = 1;
                }
                allmoney += txt_avg_moneyint*txt_popleint;
            }
            if(people_flag == 1){
                layer.msg("{:__('得奖人数不能为空或者0且只能整数')}",{icon:3});
                return false;
            }
            if(money_flag == 1){
                layer.msg("{:__('平分奖金不能为空或者0且只能整数')}",{icon:3});
                return false;
            }
            if(parseInt(allmoney)>parseInt(money)){
                layer.msg("{:__('多人中标总金额不能大于任务金额')}",{icon:3});
                return false;
            }

        } else if(slt_bid_mode == 3){
            var gj_money = $("#gj_money").val();
            var gj_moneyint = parseInt(gj_money);
            if(gj_money == '' || gj_money == null || gj_money == undefined || gj_money == 0){
                layer.msg("{:__('计件金额不能为空或0')}",{icon:3});
                return false;
            }
            if(gj_money != gj_moneyint){
                layer.msg("{:__('计件金额只能为整数')}",{icon:3});
                return false;
            }
            var gj_num = $("#gj_num").val();
            var gj_numint = parseInt(gj_num);
            if(gj_num == '' || gj_num == null || gj_num == undefined || gj_num == 0){
                layer.msg("{:__('计件数不能为空或0')}",{icon:3});
                return false;
            }
            if(gj_num != gj_numint){
                layer.msg("{:__('计件数只能为整数')}",{icon:3});
                return false;
            }
            var allmoney = gj_moneyint*gj_numint;
            if(parseInt(allmoney)>parseInt(money)){
                layer.msg("{:__('计件中标总金额不能大于任务金额')}",{icon:3});
                return false;
            }
        } else if(slt_bid_mode == 1){

        } else {
            layer.msg("{:__('页面加载失败请刷新界面重新操作')}",{icon:3});
            return false;
        }
        var days_expire = $("#days_expire").val();
        days_expireint = parseInt(days_expire);
        if(days_expire == '' || days_expire == null || days_expire == undefined || days_expire == 0){
            layer.msg("{:__('任务周期不能为空或0')}",{icon:3});
            return false;
        }
        if(days_expire != days_expireint){
            layer.msg("{:__('任务周期只能为整数')}",{icon:3});
            return false;
        }
        if(days_expireint>999){
            layer.msg("{:__('任务周期只能为三位数')}",{icon:3});
            return false;
        }
        var sign_limit = $("#sign_limit").val();
        sign_limitint = parseInt(sign_limit);
        if(sign_limit == '' || sign_limit == null || sign_limit == undefined || sign_limit == 0){
            layer.msg("{:__('报名人数限制不能为空或0')}",{icon:3});
            return false;
        }
        if(sign_limit != sign_limitint){
            layer.msg("{:__('报名人数限制只能为整数')}",{icon:3});
            return false;
        }
        if(sign_limitint>9999){
            layer.msg("{:__('报名人数限制不能超过9999')}",{icon:3});
            return false;
        }
        if($("#read_rule").prop("checked") == false){
            layer.msg("{:__('未接受发布规则与协议')}",{icon:3});
            return false;
        }
        var formdata = {
            'cat_id_1':cat_id_1,
            'cat_id':cat_id,
            'title':title,
            'content':content,
            'money':money,
            'money_cfg':{
                'slt_bid_mode':slt_bid_mode
            },
            'days_expire':days_expire,
            'sign_limit':sign_limit,
            'token':token
        };
        if(attach != ''){
            formdata.attach=attach;
        }
        if(slt_bid_mode == 2){
            var len = $(".money_setting").length;
            for(i=1;i<len;i++){
                formdata["money_cfg"]["txt_pople_"+i]=$("#people_"+i).val();
                formdata['money_cfg']['txt_avg_money_'+i]=$("#money_"+i).val();
            }
            formdata.money_setting=len;
        } else if(slt_bid_mode == 3){
            formdata.money_cfg.gj_num=$("#gj_num").val();
            formdata.money_cfg.gj_money=$("#gj_money").val();
        }
        var formdatastr = JSON.stringify(formdata);
        localStorage.setItem("taskinfo",formdatastr);
        window.location.href="/index/Task/taskconfirm";

    });
    $("#attach_copy").click(function(){
        $("#attach").val("");
        $("#attach").trigger("click");
    });

    $("#attach").change(function(){
        var filename = $("#attach")[0].files[0].name;
        $("#file_name").html(filename);
        $("#attach_sub").trigger("click");
    });
    $("#changprofile").click(function(){
        var cat_id_1 = $("#cat_id_1").val();
        cat_id_1 = parseInt(cat_id_1);
        var cat_id = $("#cat_id").val();
        cat_id = parseInt(cat_id);
        var title = $("#title").val();
        var content = editor.txt.html();
        var attach = $("#attach").attr("src");
        if(attach == '' || attach == null || attach == undefined){
            attach = '';
        }
        var  money = $("#money").val();
        moneycopy = parseInt(money);
        var slt_bid_mode = $("#slt_bid_mode").val();
        slt_bid_mode = parseInt(slt_bid_mode);
        if(slt_bid_mode == 2){
            var money_flag = 0;
            var people_flag = 0;
            var len = $(".money_setting").length;
            var allmoney = 0;
            for(i=1;i<len;i++){
                // 平分奖金校验
                var txt_avg_money = $("#money_"+i).val();
                var txt_avg_moneyint = parseInt(txt_avg_money);
                if(txt_avg_money == '' || txt_avg_money == null || txt_avg_money == undefined || txt_avg_money == 0){
                    money_flag = 1;
                }
                if(txt_avg_money != txt_avg_moneyint){
                    money_flag = 1;
                }
                // 人数校验
                var txt_pople = $("#people_"+i).val();
                var txt_popleint = parseInt(txt_pople);
                if(txt_pople == '' || txt_pople == null || txt_pople == undefined || txt_pople == 0){
                    people_flag = 1;
                }
                if(txt_pople != txt_popleint){
                    people_flag = 1;
                }
            }

        } else if(slt_bid_mode == 3){
            var gj_money = $("#gj_money").val();
            var gj_moneyint = parseInt(gj_money);
            var gj_num = $("#gj_num").val();
            var gj_numint = parseInt(gj_num);
        }
        var days_expire = $("#days_expire").val();
        days_expireint = parseInt(days_expire);
        var sign_limit = $("#sign_limit").val();
        sign_limitint = parseInt(sign_limit);
        var formdata = {
            'cat_id_1':cat_id_1,
            'cat_id':cat_id,
            'title':title,
            'content':content,
            'money':money,
            'money_cfg':{
                'slt_bid_mode':slt_bid_mode
            },
            'days_expire':days_expire,
            'sign_limit':sign_limit,
            'token':token
        };
        if(attach != ''){
            formdata.attach=attach;
        }
        if(slt_bid_mode == 2){
            var len = $(".money_setting").length;
            for(i=1;i<len;i++){
                formdata["money_cfg"]["txt_pople_"+i]=$("#people_"+i).val();
                formdata['money_cfg']['txt_avg_money_'+i]=$("#money_"+i).val();
            }
            formdata.money_setting=len;
        } else if(slt_bid_mode == 3){
            formdata.money_cfg.gj_num=$("#gj_num").val();
            formdata.money_cfg.gj_money=$("#gj_money").val();
        }
        var formdatastr = JSON.stringify(formdata);
        localStorage.setItem("taskinfo",formdatastr);
        window.location.href="/index/User/updateinfo";
    });
</script>